package train48days;

import java.util.Scanner;

public class 两种排序方式 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int n = sc.nextInt();
            String[]  word = new String[n];
            for (int i = 0; i < n; i++) {
                word[i] = sc.next();
            }
            boolean iszd = zd(word);
            boolean iscd = cd(word);
            if (iscd&&iszd){
                System.out.println("both");
            }else if (iscd&&!iszd){
                System.out.println("lengths");
            }else if (iszd&&!iscd){
                System.out.println("lexicographically");
            }else {
                System.out.println("none");
            }
        }
    }



    public static boolean  zd(String[] str){
        for (int i = 1; i < str.length ; i++) {
            if (str[i].compareTo(str[i-1])<=0){
                return false;
            }
        }
        return true;
    }
    public static boolean  cd(String[] str){
        for (int i = 1; i < str.length; i++) {
            if (str[i].length()<=str[i-1].length()){
                return false;
            }
        }
        return true;
    }

}
